package im.yisme.view.activities;

import im.yisme.view.ui.animation.Rotate3D;
import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;

public class Rotate3DActivity extends Activity{

	//3D效果
	protected Rotate3D lOutAnimation,lInAnimation,rOutAnimation,rInAnimation;
	private int mCenterX;		
	private int mCenterY;
	
	protected void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		
		initAnimation();
	}
	
	
	private void initAnimation() {
		// 获取旋转中心
		DisplayMetrics dm = new DisplayMetrics();
		dm = getResources().getDisplayMetrics();
		mCenterX = dm.widthPixels / 2;
		mCenterY = dm.heightPixels / 2;
		
		// 定义旋转方向
		int duration = 1000;
		lOutAnimation = new Rotate3D(0, -90, mCenterX, mCenterY);	// 向左转（从0度转到-90，参考系为水平方向为0度）
		lOutAnimation.setFillAfter(true);
		lOutAnimation.setDuration(duration);


		rOutAnimation = new Rotate3D(0, 90, mCenterX, mCenterY);    // 向右转（从0度转到90，参考系为水平方向为0度）
		rOutAnimation.setFillAfter(true);
		rOutAnimation.setDuration(duration);
		
		lInAnimation = new Rotate3D(-90, 0, mCenterX, mCenterY);    // 从左转进来（从-90度转到0，参考系为水平方向为0度）
		lInAnimation.setFillAfter(true);
		lInAnimation.setDuration(duration);
		
		rInAnimation = new Rotate3D(90, 0, mCenterX, mCenterY);     // 从右转进来（从90度转到0，参考系为水平方向为0度）
		rInAnimation.setFillAfter(true);
		rInAnimation.setDuration(duration);

	}
}
